package day0715;

import com.sun.org.apache.bcel.internal.generic.ARETURN;

import java.util.Random;
import java.util.Scanner;

public class test5 {
    public static void main(String[] args) {
        Random r = new Random();
        int num = r.nextInt(20);//0---20
        System.out.println(num);
        String a = guessNum(num);
        System.out.println(a);
    }

    static String guessNum(int num2) {
        Scanner s = new Scanner(System.in);
        for (int i = 0; i >= 0; i++) {
            int n = s.nextInt();
            if (n == num2) {
                return "恭喜你猜对了";//返回结果，还能结束guessNum函数的执行
            }
            if (n > num2) {
                System.out.println("猜大了，请重新猜");
            }else{
                System.out.println("猜小了，请重新猜");
            }
        }
        return "";
    }
}
